
/**
 * Shows/hides element content.
 * 
 * Borrowed from http://www.jakpsatweb.cz/javascript/priklady/skryvani-odkryvani.html
 */
function showHide(id){
    el=document.getElementById(id).style; 
    el.display=(el.display == 'block')?'none':'block';
}

/**
 * Manages selection/deselection of superior checkboxes when
 * sensor checkboxes are selected/deselected
 *
 * @author Vladimir Cerven <v.cerven@gmail.com>
 */
function checkChecked(group){
    $("#"+group).attr("checked", true);
    $("."+group).each(function(i){
        if(!$(this).is(":checked")){
            $("#"+group).attr("checked", false);
            return;
        }
    });	
}


$(document).ready(function(){
    /**
     * Check on load if are selected all sensors in some group
     * if they are, it check also superior checkbox
     * 
     * @author Vladimir Cerven <v.cerven@gmail.com>
     */
    $(".groupBox").each(function(i){
        checkChecked($(this).attr("id"));
    });
    
    /**
     * Manages selection/deselection of checkboxes when superior checkbox is
     * selected/deselected
     * 
     * @author Vladimir Cerven <v.cerven@gmail.com>
     */
    $(".groupBox").click(function(){
        $("."+$(this).attr("id")).attr("checked", $(this).is(":checked"));
    });
});


